/*
 * Created by JFormDesigner on Wed Apr 28 16:59:59 CST 2021
 */

package com.lgz.dbcourse.gui;

import com.lgz.dbcourse.dto.AudienceDTO;
import com.lgz.dbcourse.dto.MyMovie;
import com.lgz.dbcourse.service.UserService;
import com.lgz.dbcourse.service.impl.UserServiceImpl;

import java.awt.*;
import javax.swing.*;

/**
 * @author Brainrain
 */
public class Me extends JDialog {
    private UserService userService;
    public Me(Window owner) {
        super(owner);
        initComponents();
        this.setModal(true);
        userService = new UserServiceImpl();
    }

    public Me(Window owner, AudienceDTO audienceDTO) {
        this(owner);
        this.label1.setText(audienceDTO.getAudienceDisplay());
        MyMovie[] myMovies = (MyMovie[])userService.getMyMovie(audienceDTO.getAudienceId()).getData();
        String[] data = new String[myMovies.length];
        for (int i = 0; i < myMovies.length; i++) {
            data[i] = myMovies[i].toString();
        }
        this.list1.setListData(data);
    }

    public void start() {
        this.setVisible(true);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        panel1 = new JPanel();
        panel2 = new JPanel();
        panel3 = new JPanel();
        panel4 = new JPanel();
        panel5 = new JPanel();
        label1 = new JLabel();
        scrollPane1 = new JScrollPane();
        list1 = new JList<>();

        //======== this ========
        setTitle("\u6211\u7684");
        setMinimumSize(new Dimension(710, 250));
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== panel1 ========
        {
            panel1.setPreferredSize(new Dimension(30, 0));
            panel1.setLayout(new BorderLayout());
        }
        contentPane.add(panel1, BorderLayout.WEST);

        //======== panel2 ========
        {
            panel2.setPreferredSize(new Dimension(0, 30));
            panel2.setLayout(new BorderLayout());
        }
        contentPane.add(panel2, BorderLayout.NORTH);

        //======== panel3 ========
        {
            panel3.setPreferredSize(new Dimension(0, 30));
            panel3.setLayout(new BorderLayout());
        }
        contentPane.add(panel3, BorderLayout.SOUTH);

        //======== panel4 ========
        {
            panel4.setPreferredSize(new Dimension(30, 0));
            panel4.setLayout(new BorderLayout());
        }
        contentPane.add(panel4, BorderLayout.EAST);

        //======== panel5 ========
        {
            panel5.setLayout(new BorderLayout());

            //---- label1 ----
            label1.setText("text");
            label1.setHorizontalAlignment(SwingConstants.CENTER);
            label1.setPreferredSize(new Dimension(21, 30));
            panel5.add(label1, BorderLayout.NORTH);

            //======== scrollPane1 ========
            {
                scrollPane1.setViewportView(list1);
            }
            panel5.add(scrollPane1, BorderLayout.CENTER);
        }
        contentPane.add(panel5, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JPanel panel1;
    private JPanel panel2;
    private JPanel panel3;
    private JPanel panel4;
    private JPanel panel5;
    private JLabel label1;
    private JScrollPane scrollPane1;
    private JList<String> list1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
